#!/bin/bash

# 打印logo和描述信息
logo=$(cat <<'EOF'
  _____ _                         _   _             _
 / ____| |                   /\  | | | |           | |
| (___ | | _____      __    /  \ | |_| |_ __ _  ___| | __
 \___ \| |/ _ \ \ /\ / /   / /\ \| __| __/ _` |/ __| |/ /
 ____) | | (_) \ V  V /   / ____ \ |_| || (_| | (__|   <
|_____/|_|\___/ \_/\_/   /_/    \_\__|\__\__,_|\___|_|\_\
EOF
)
echo -e "$logo"
echo -e "\033[1;32;40m[*] 慢速攻击是一种针对目标系统的网络安全攻击，通过持续发送低频率请求，逐渐占用其资源或网络带宽，最终导致服务不可用或系统性能下降。\033[1;37;40m"

# 定义文件字典
declare -A files
files=(
     ["1"]="ddos_cn/Slow_Attack/Slow_Read_attack.py"
     ["2"]="ddos_cn/Slow_Attack/Slowloris_attack.py"
     ["3"]="ddos_cn/Slow_Attack/Slow_POST_attack.py"
     ["4"]="ddos_cn/Slow_Attack/Slow_GET_attack.py"
     ["5"]="ddos_cn/Slow_Attack/Slow_DNS_attack.py"
     ["6"]="ddos_cn/Slow_Attack/slow_write_attack.py"
     ["7"]="ddos_cn/Slow_Attack/Slow_SSL_attack.py"
)

# 使用whiptail创建菜单
while true; do
     choice=$(whiptail --title "慢速攻击类型" --menu "慢速攻击是一种针对目标系统的网络安全攻击，通过持续发送低频率请求，逐渐占用其资源或网络带宽，最终导致服务不可用或系统性能下降。\n\n请选择攻击模式：" 35 78 20 \
     "1" "慢速读取攻击" \
     "2" "Slowloris攻击" \
     "3" "慢速POST攻击" \
     "4" "慢速GET攻击" \
     "5" "慢速DNS攻击" \
     "6" "慢速写入攻击" \
     "7" "慢速SSL攻击" \
     "0" "返回" \
     3>&1 1>&2 2>&3)

     if [[ $? -eq 0 ]]; then
         if [[ "$choice" == "0" ]]; then
             echo "操作已取消。"
             break
         else
             python3 "${files[$choice]}"
             break
         fi
     else
         echo "操作已取消。"
         break
     fi
done
